﻿using CloudDcPc.Entity;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace CloudDcPc.FuckDlg
{
    /// <summary>
    /// MenuTypeAddDlg.xaml 的交互逻辑
    /// </summary>
    public partial class MenuTypeAddDlg : Window
    {
        ObservableCollection<MenuType> all_MenuType = new ObservableCollection<MenuType>();
        public MenuTypeAddDlg(ObservableCollection<MenuType> all_MenuType)
        {
            this.all_MenuType = all_MenuType;
            InitializeComponent();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            string name = txt_name.Text;
            if (name == "")
            {
                MessageBox.Show("名称不能为空！");
                return;
            }
            string djqcanuse = cb_djqcanuse.SelectedValue.ToString();
            string hykcanuse = cb_hykcanuse.SelectedValue.ToString();
            MenuType menuType = new MenuType()
            {
                Name = name,
                TextDjqcanuse = djqcanuse,
                TextHykcanuse = hykcanuse
            };

            if (App.MenuTypeBean.AddMenuType(menuType))
            {
                MessageBox.Show("添加成功！");
                all_MenuType.Add(menuType);
                this.Close();
            }
            else
            {
                MessageBox.Show("添加失败！");
            }
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
